package es.uji.viselab.experiment;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;

import es.uji.viselab.ViSeLabComponent;
import es.uji.viselab.benchmark.BenchMarkingRecorder;
import es.uji.viselab.benchmark.DataPackage;
import es.uji.viselab.image.source.ImageListener;
import es.uji.viselab.image.source.ImageSource;
import es.uji.viselab.robot.Robot;
import es.uji.viselab.robot.RobotListener;
import es.uji.viselab.visualservoing.VisualServoingTask;

public abstract class ExperimentInterface implements ImageListener, RobotListener,
		DataArrivalListener,ViSeLabComponent, ActionListener {

	protected BenchMarkingRecorder benchmarking;
	protected Experiment experiment;
	protected ExperimentParameters ep;
	protected Robot robot;
	protected VisualServoingTask visualServoing;


	public ExperimentInterface(BenchMarkingRecorder bm) {
		benchmarking = bm;
	}

	public ExperimentInterface(ExperimentParameters ep) {
		this.ep = ep;
	}

	public Experiment getExperiment() {
		return experiment;
	}
	

	public abstract JPanel getPanel();

	/*public static ExperimentInterface getDefaultExperiment() {
		BenchMarkingRecorder benchmarkingSystem = new BenchMarkingRecorder();
		ExperimentCustomizable experimentInterface = new ExperimentCustomizable(benchmarkingSystem);
		// experimentInterface.setExperiment(new Experiment3());
		return experimentInterface;
	}*/

	@Override
	public void newConnectionStablished() {
		// TODO Auto-generated method stub

	}

	/*@Override
	public void newDataArrived(DataPackage dn) {
		// TODO Auto-generated method stub

	}*/

	@Override
	public void robotPositionChanged(Robot robot) {
		// TODO Auto-generated method stub

	}

	@Override
	public void robotCreated(Robot robot) {
		// TODO Auto-generated method stub

	}

	@Override
	public void robotConnected(Robot robot) {
		// TODO Auto-generated method stub

	}

	@Override
	public void robotDisconnected() {
	}

	@Override
	public void cameraFeaturePointsChanged(ImageSource i) {
		if (experiment != null)
			experiment.cameraFeaturePointsChanged(i);
	}

	public void setRobot(Robot robot) {
		this.robot = robot;
	}

	public void setVSTask(VisualServoingTask vs) {
		this.visualServoing=vs;
	}

	public void start() {
		experiment.setRobot(robot);
		experiment.setVisualServoing(visualServoing);
		experiment.start();}

	public void setExperiment(Experiment e) {
	 this.experiment=e;
		
	}
	@Override
	public void newDataArrived(DataPackage dp) {
	}
	
	@Override
	public void actionPerformed(ActionEvent ae) {
		
	}
}
